# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=soundfile
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.12.1
pkgrel=2
pkgdesc='An audio library based on libsndfile, CFFI and NumPy (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
url="https://github.com/bastibe/SoundFile"
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python-cffi" "${MINGW_PACKAGE_PREFIX}-python-numpy" "${MINGW_PACKAGE_PREFIX}-libsndfile")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz"
        0001-fix-libsndfile-dll.patch)
sha256sums=('e8e1017b2cf1dda767aef19d2fd9ee5ebe07e050d430f77a0a7c66ba08b8cdae'
            'd8236f80c1c105f29ea55d160bfb4958311dfa24847f55133cbc00ab0f4320e7')

prepare() {  
  pushd "${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}/0001-fix-libsndfile-dll.patch"
  popd

  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
